//
//  bayTimeTVCell.m
//  jiMuOperate
//
//  Created by 翁仪 on 16/5/5.
//  Copyright © 2016年 jinXinFengLi. All rights reserved.
//

#import "bayTimeTVCell.h"

@implementation bayTimeTVCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createViewTitel:@"拟买出时间段 :"];
        //        [self setingDate];
    }
    return self;
}
-(void)createViewTitel:(NSString *)titel
{
    CGFloat padingW=15;
    UILabel *biddingLabel = [ARC createLabelWithFrame:CGRectMake(padingW, 5, 100, 30) Font:14 Text:titel];
    //    UILabel *biddingLabel = [ARC createLabelWithFrame:CGRectMake(padingW, 5, 100, 20) Font:14 Text:@"拟买入时间段："];
    biddingLabel.textColor = [UIColor blackColor];
    //    biddingLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:biddingLabel];
    
    UIView *view1 = [self baseViewFrame:CGRectMake(padingW, biddingLabel.frame.size.height, (SCREEN_WIDTH-padingW*2)*0.5, 20) imageNamed:@"aut_ico_agree" Selected:@"aut_ico_agree" butTag:1001 titel:@"竞价:" timeTitel:@"09:15~09:30"];
    //        view1.backgroundColor = [UIColor redColor];
    
    UIView *view2 = [self baseViewFrame:CGRectMake(view1.frame.origin.x+view1.frame.size.width, biddingLabel.frame.size.height, (SCREEN_WIDTH-padingW*2)*0.5, view1.frame.size.height) imageNamed:@"aut_ico_agree" Selected:@"aut_ico_agree" butTag:1002 titel:@"早盘:" timeTitel:@"09:30~10:00"];
    
    UIView *view3 = [self baseViewFrame:CGRectMake(view1.frame.origin.x, view1.frame.origin.y+view1.frame.size.height, (SCREEN_WIDTH-padingW*2)*0.5, view1.frame.size.height) imageNamed:@"aut_ico_agree" Selected:@"aut_ico_agree" butTag:1003 titel:@"中盘:" timeTitel:@"10:00~11:30"];
    //    view3.backgroundColor = [UIColor blueColor];
    
    UIView *view4 = [self baseViewFrame:CGRectMake(view3.frame.origin.x+view3.frame.size.width, view3.frame.origin.y, (SCREEN_WIDTH-padingW*2)*0.5, view1.frame.size.height) imageNamed:@"aut_ico_agree" Selected:@"aut_ico_agree" butTag:1004 titel:@"午盘:" timeTitel:@"13:00~14:00"];
    
    UIView *view5 = [self baseViewFrame:CGRectMake(view3.frame.origin.x, view3.frame.origin.y+view1.frame.size.height, (SCREEN_WIDTH-padingW*2)*0.5, view1.frame.size.height) imageNamed:@"aut_ico_agree" Selected:@"aut_ico_agree" butTag:1005 titel:@"尾盘:" timeTitel:@"14:00~15:00"];
    
    UIView *view6 = [self baseViewFrame:CGRectMake(view5.frame.origin.x+view5.frame.size.width, view5.frame.origin.y, (SCREEN_WIDTH-padingW*2)*0.5, view1.frame.size.height) imageNamed:@"aut_ico_agree" Selected:@"aut_ico_agree" butTag:1006 titel:@"全天" timeTitel:@""];
    [self.contentView addSubview:view1];
    [self.contentView addSubview:view2];
    [self.contentView addSubview:view3];
    [self.contentView addSubview:view4];
    [self.contentView addSubview:view5];
    [self.contentView addSubview:view6];
    
}
-(UIView *)baseViewFrame:(CGRect)Frame imageNamed:(NSString *)imageNamed Selected:(NSString *)SelectedImageNamed butTag:(NSInteger)butTag titel:(NSString *)titel timeTitel:(NSString *)timeTitel {
    
    UIView *baseView = [ARC createViewWithFrame:Frame];
    //    baseView.backgroundColor = [UIColor redColor];
    
    UIButton *but1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    [but1 setImage:[UIImage imageNamed:imageNamed] forState:UIControlStateNormal];
    //    but1.selected = YES;
    [but1 setImage:[UIImage imageNamed:SelectedImageNamed] forState:UIControlStateSelected];
    but1.tag = butTag;
    [but1 addTarget:self action:@selector(bayBtnClick:)
   forControlEvents:UIControlEventTouchUpInside];
    [but1 setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
    
    UILabel *Label1 = [ARC createLabelWithFrame:CGRectMake(but1.frame.origin.x+but1.frame.size.width, 0, 40, 30) Font:12 Text:titel];
    Label1.textAlignment = NSTextAlignmentLeft;
    Label1.textColor = [UIColor blackColor];
    UILabel *timeLabel1 = [ARC createLabelWithFrame:CGRectMake(Label1.frame.origin.x+Label1.frame.size.width, 0, 100, 30) Font:11 Text:timeTitel];
    timeLabel1.textAlignment = NSTextAlignmentLeft;
    timeLabel1.textColor = RGB(169, 169, 169);
    
    [baseView addSubview:timeLabel1];
    [baseView addSubview:Label1];
    [baseView addSubview:but1];
    
    return baseView;
}
-(void)bayBtnClick:(UIButton *)button{
    
    switch (button.tag) {
        case BuyBidBtn:
            NSLog(@"买入竞价");
             _buyChoiceTime = @"09:15~09:30";
            break;
        case BuyAMBtn:
            NSLog(@"买入早盘");
            _buyChoiceTime = @"09:30~10:00";

            break;
        case BuyNoonBtn:
            NSLog(@"买入中盘");
            _buyChoiceTime = @"10:00~11:30";

            break;
        case BuyPMBtn:
            NSLog(@"买入午盘");
            _buyChoiceTime = @"13:00~14:00";

            break;
        case BuyNightBtn:
            NSLog(@"买入尾盘");
            _buyChoiceTime = @"14:00~15:00";

            break;
        case BuyAllBtn:
            NSLog(@"买入全天");
            _buyChoiceTime = @"全天";

            break;
            
        default:
            break;
    }
}
@end
